First, let's initialize
a local Git repository by going into a project
folder and initializing Git. We can initialize Git
by typing git init. In your terminal, you can
see that we initialize an empty Git repository
in a.git folder. When you execute
the ls -a command in order to list all the
contents of the folder, including hidden folders,
such as the git folder, you can see that the git
folder has been created. Later on in the chorus, I'll talk more about
what git actually does and the contents
of the git folder, but for now, it's just important to understand
the flow of Git. Let's add a file to our project. It's going to be a
simple text file with a very basic sentence. We've just made a new
file and added the text, "This is a beautiful
story to it." I'm proud of my creation, and I want to make
sure that I save the current state
the project is in, so I'm going to save that
to my local Git repository. Now that we've added
the text file, let's see if Git saw
that I made a change. Although we haven't done
anything with Git yet, we initialized a Git
repository in this project, so Git knows all of our
files and their changes. You can see the status of Git by executing the git
status command. Let's see step by step what
this output actually means. First, on branch master. We haven't covered branches yet. However, Git allows
you to work on your code and have multiple
states of your codebase. Your default branch
is the master branch. As we haven't made
any new branches yet, we're still on the default
master branch. No commits yet. Storing changes in our local Git repository
is called committing. With every commit, we
save the current state of the repository and show the
changes that we made to it. We haven't done so yet, so there are no commits yet, as Git tells us. Untracked files. These are
the files that Git knows off. However, we haven't told
Git what to do with them. We haven't told it
yet that we want to add it to our local repository, for example, so they're
still untracked. Right now, we haven't
told Git what to do with a new story1.txt file. It might be that we
don't want to add that story to our local
repository at all. However, I want to
commit my change. Before we can commit a file, we first have to put it
in the staging area. We can put it in
the staging area with the git add command. You run the git add command with the files that we want to
add to the staging area. In this case, I want to add the story1.txt file to
the staging area, so I execute git add story1.txt. Perfect. Now it's time
to commit our change. A commit records the change of a repository compared
to its previous state. In this case, we didn't
have any previous commits, so the addition of the files story1.txt is a change compared
to its previous state. In order to commit the files that are currently
in the staging area, we run the git commit -m command with a useful
message right after. The -m is a fleck from message. When you make a commit,
it's very good practice to summarize the change
that you just made in a very short sentence. This way, you can easily track down when you
made certain changes, and your teammates also know
what you've been doing. In this case, I'm
committing my first story, so I'm going to add the
message, "Added first story." We just created our
very first commit. The changes have been saved, and we can reset our project to this exact state at any
point in the future. Okay.